package com.work.music.utils;

import java.util.HashMap;
import java.util.Map;

public class Pagecode {
	static int pagecode = 1;
	public static Map<String, Object> pagecode(int nowpage, int count){
		Map<String, Object> map = new HashMap<String, Object>();
		int pages = 0;
		if(nowpage <= 0) {
			nowpage = 1;
		} else if(nowpage > count / pagecode && count % pagecode != 0) {
			nowpage = count / pagecode + 1;
			pages = count / pagecode + 1;
		} else if(nowpage > count / pagecode && count % pagecode == 0) {
			nowpage = count / pagecode;
			pages = count / pagecode;
		}
		if(count % pagecode == 0) {
			pages = count / pagecode;
		} else {
			pages = count / pagecode + 1;
		}
		map.put("pages", pages);
		map.put("nowpage", nowpage);
		int start = (nowpage-1) * pagecode;
		map.put("start", start);
		map.put("count", pagecode);
		return map;
	}
}
